/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../mixins/tip.less';
@import '../mixins/input.less';
@import '../mixins/common.less';
@import '../custom.less';
@import './vars.less';
@pager-prefix-cls: ~'@{css-prefix}pager';
@popover-prefix-cls: ~'@{css-prefix}popover';
@popper-prefix-cls: ~'@{css-prefix}popper';

.@{pager-prefix-cls} {
  .component-css-vars-pager();

  text-align: left;
  padding: 12px 0;
  color: var(--ti-pager-text-color);

  & &__group {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    font-size: var(--ti-pager-font-size);

    > span {
      display: inline-block;
      vertical-align: middle;
    }
  }

  & &__total {
    height: 24px;
    line-height: 24px;
    font-size: 12px;
    color: var(--ti-pager-normal-text-color);
  }

  & &__pages {
    display: inline-flex;
    font-size: var(--ti-pager-font-size);

    li {
      background: transparent;
      display: inline-block;
      font-size: var(--ti-pager-font-size);
      cursor: pointer;
      margin-right: 4px;
      text-align: center;
      line-height: var(--ti-pager-height);
      border-radius: var(--ti-pager-input-border-radius);
      height: var(--ti-pager-height);
      color: var(--ti-pager-text-color);
      padding: var(--ti-pager-poplist-item-padding-vertical) var(--ti-pager-poplist-item-padding-horizontal);
      box-sizing: border-box;
      border: 1px solid transparent;
      transition: all 0.5s ease;

      a {
        color: var(--ti-pager-text-color);
      }

      svg {
        fill: var(--ti-pager-text-color);
        vertical-align: middle;
      }

      &:not(.dot):not(.is-active):hover {
        color: var(--ti-pager-poplist-item-hover-text-color);
        background-color: var(--ti-pager-poplist-item-hover-bg-color);
        box-shadow: var(--ti-pager-poplist-item-unchecked-box-shadow);
        border: 1px solid var(--ti-pager-poplist-item-hover-border-color);
        svg {
          fill: var(--ti-pager-poplist-item-hover-text-color);
        }
      }

      &.dot {
        .icon {
          font-size: 14px;
        }
      }

      &.is-active {
        color: #fff;
        background-color: var(--ti-pager-primary-bg-color);
      }
    }
    li:last-child {
      margin-right: 0;
    }
  }

  &__goto {
    font-size: 0;

    input[type='text'] {
      width: var(--ti-pager-input-width);
      text-align: center;
      vertical-align: middle;
      border-radius: var(--ti-pager-input-border-radius);
      display: inline-block;
      position: inherit;
      height: var(--ti-pager-input-height);
      line-height: var(--ti-pager-input-height);
      border: 1px solid var(--ti-pager-input-border-color);
      color: var(--ti-pager-normal-text-color);
      font-size: var(--ti-pager-font-size);
      transition: border 0.3s;
      outline: 0;
      box-sizing: border-box;
      margin-left: 14px;
      margin-right: 4px;

      &:hover {
        border: 1px solid var(--ti-pager-input-hover-border-color);
        color: var(--ti-pager-normal-text-color);
      }

      &:focus,
      &:active,
      &.active,
      &[active] {
        border: 1px solid var(--ti-pager-primary-border-color);
        box-shadow: 0 0 0 rgba(0, 0, 0, 0);
      }
    }

    button {
      height: var(--ti-pager-input-height);
      line-height: var(--ti-pager-input-height);
      border: 1px solid #d9d9d9;
      color: var(--ti-pager-text-color);
      vertical-align: middle;
      border-radius: var(--ti-pager-input-border-radius);
      background: #fff;
      font-size: var(--ti-pager-font-size);
      padding: 0 8px;
      text-align: center;
      display: inline-block;
      box-sizing: border-box;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      cursor: pointer;
      transition: border 0.3s, color 0.3s, background 0.3s;
      outline: 0;
      .user-select(none);
      &:hover {
        border: 1px solid var(--ti-pager-goto-btn-border-color);
        color: var(--ti-pager-goto-btn-text-color);
      }
    }
  }

  &__btn-prev,
  &__btn-next {
    height: var(--ti-pager-height);
    line-height: var(--ti-pager-height);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: var(--ti-pager-font-size);
    font-weight: bolder;
    color: var(--ti-pagination-prev-next-color);
    outline: none;
    border: none;
    background: transparent;
    margin: 0 4px;
    padding: 0 6px;
    vertical-align: middle;
    cursor: pointer;

    span {
      color: var(--ti-pager-primary-text-color);
    }

    svg {
      fill: var(--ti-pager-normal-text-color);
      font-size: var(--ti-pager-font-size);
      vertical-align: middle;
    }

    &:hover {
      background-color: var(--ti-pager-poplist-item-hover-bg-color);
      svg {
        fill: var(--ti-pager-poplist-item-hover-text-color);
      }
    }

    &[disabled] {
      &,
      &:hover {
        background-color: transparent;
        cursor: not-allowed;
      }

      span {
        color: var(--ti-pager-prev-next-text-color-disabled);
      }

      svg {
        fill: var(--ti-pager-prev-next-text-color-disabled);
      }
    }
  }

  &__selector {
    &.@{popover-prefix-cls}.@{popper-prefix-cls} {
      width: 60px;
      padding: 0;

      &[x-placement^='bottom'] {
        margin-top: 2px;
      }

      &[x-placement^='top'] {
        margin-bottom: 0;
      }
    }

    &-body {
      max-height: 300px;
      overflow-y: auto;
      overflow-x: hidden;
    }

    &-poplist {
      .list-item {
        min-height: 30px;
        padding: 0 8px;
        line-height: 30px;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;

        &:hover {
          cursor: pointer;
          background: var(--ti-pager-poplist-item-hover-bg-color);
          color: var(--ti-pager-poplist-item-hover-text-color);
        }

        &.is-selected {
          background: var(--ti-pager-poplist-item-selected-bg-color);
          color: var(--ti-pager-normal-text-color);

          &:hover {
            background: var(--ti-pager-poplist-item-selected-bg-color);
          }
        }

        &.select-pre {
          background: var(--ti-pager-poplist-item-hover-bg-color);
          color: var(--ti-pager-poplist-item-hover-text-color);

          &.is-selected {
            color: #fff;
            background: var(--ti-pager-poplist-item-selected-bg-color);
          }
        }
      }
    }
  }

  & &__popover {
    margin: 0 4px 0 14px;
  }

  & &__sizes {
    .@{pager-prefix-cls}__popover {
      margin: 0;
    }
    & + .@{pager-prefix-cls}__group {
      margin: 0 16px;
    }
  }

  & &__group {
    & + .@{pager-prefix-cls}__sizes {
      margin: 0 16px;
    }
  }

  &__input {
    width: 60px;
    vertical-align: middle;
    position: relative;

    input {
      width: 100%;
      height: var(--ti-pager-input-height);
      line-height: var(--ti-pager-input-height);
      border: 1px solid var(--ti-pager-input-border-color);
      color: var(--ti-pager-normal-text-color);
      border-radius: var(--ti-pager-input-border-radius);
      background: #fff;
      font-size: var(--ti-pager-font-size, 12px);
      padding: 0 8px;
      display: block;
      stop-color: var(--ti-pager-input-stop-color);
      lighting-color: var(--ti-pager-input-lighting-color);
      padding: 6px 10px;
      white-space: nowrap;
      transition: border 0.3s;
      outline: 0;
      box-sizing: border-box;
      .user-select(none);

      &:hover {
        outline: 0;
        border-color: var(--ti-pager-input-hover-border-color);
      }

      &:active,
      &:focus {
        outline: 0;
        border-color: var(--ti-pager-input-hover-border-color);
      }
    }

    &-btn {
      width: 24px;
      height: var(--ti-pager-height);
      line-height: var(--ti-pager-height);
      position: absolute;
      right: 2px;
      bottom: 0;
      top: 0;
      outline: 0;
      box-sizing: border-box;
      text-align: center;
      overflow: hidden;
      cursor: pointer;

      svg {
        font-size: var(--ti-pager-font-size);
        fill: var(--ti-pager-font-normal-text-color);
        vertical-align: middle;
      }
    }
  }

  .@{popover-prefix-cls}__reference {
    outline: 0;
  }
}

@media (max-width: 768px) {
  .@{pager-prefix-cls} {
    text-align: left;

    & &__pull-left {
      float: none !important;
    }
  }
}
